from datetime import datetime
from pydantic import BaseModel
from typing import Optional, List, Any
from app.schemas.base_model import OrmBaseModel

# Shared properties
from app.schemas.chart import StrategyParam


class PickerBase(OrmBaseModel):
    id: Optional[int]
    userId: Optional[int]
    exchangeId: Optional[int]
    frequency: Optional[str]
    startDate: Optional[datetime]
    endDate: Optional[datetime]
    pickCount: Optional[int]
    filterCount: Optional[int]
    total: Optional[int]
    strategyConditions: Optional[str]
    publicConditions: Optional[str]
    createdDate: Optional[datetime]
    updatedDate: Optional[datetime]


class PickerQuery(PickerBase):
    realTime: Optional[bool]


class ExpressionParam(BaseModel):
    variable: str
    operator: str
    value: str
    parsedExpr: str


class StrategyConditionParam(BaseModel):
    strategyId: int
    description: str
    pickDate: datetime
    strategyParams: Optional[List[StrategyParam]]
    expressions: List[ExpressionParam]


class PublicConditionParam(BaseModel):
    isRemoveSt: bool
    isRemoveUntrade: bool
    isAdjustFore: bool


class PickerRange(BaseModel):
    exchangeId: int
    # 板块


class PickerCreate(BaseModel):
    frequency: str
    range: PickerRange
    strategyConditions: List[StrategyConditionParam]
    publicConditions: PublicConditionParam


class PickerTask(BaseModel):
    pickerId: int
    instrumentIds: List[int]
    realTime: bool



class CeleryTaskMsg(BaseModel):
    msgId: str
    msgDate: datetime
    msgBody: Any
